<?php
/**
 * Core_View_Helper_Messages
 *
 * @author naspeh
 * @version $Id$
 */
class Core_View_Helper_Messages
{
    /**
     * Возвращает сообщения
     *
     * @return string
     */
    public function messages()
    {
        $content = '';
        if (Core_Message::has()) {
        	foreach (Core_Message::get() as $body => $type) {
        		$content .= $this->build($body, $type) . PHP_EOL;
        	}
        }
        return $content;
    }
    /**
     * Строит сообщение
     *
     * @param string $body
     * @param string $type
     * @return string
     */
    public function build($body, $type)
    {
        $class = Core_Message::getClass($type);
        $body = (string) $body;
        return '<div class="' . $class . '">' . $body . '</div>';
    }
}